package edu.neu.javaweb.controller;

import edu.neu.javaweb.bean.Dept;
import edu.neu.javaweb.bean.Employee;
import edu.neu.javaweb.service.DeptService;
import edu.neu.javaweb.service.EmployeeService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/pages/emp_list")
public class EmpListServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("UTF-8");
        response.setCharacterEncoding("UTF-8");

        List<Employee> list = new EmployeeService().findAll();
        List<Dept> dlist = new DeptService().findAll();
        request.setAttribute("list", list);
        request.setAttribute("ls", list);
        request.setAttribute("dlist", dlist);
        request.getRequestDispatcher("emp_list.jsp").forward(request, response);
    }
}
